using System;
using System.Windows;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using UnityConfiguration;

namespace sonic.Samples.Client
{
    public class Bootstrapper : UnityBootstrapper
    {
        protected override IModuleCatalog GetModuleCatalog() {
            return
                ModuleCatalog.CreateFromXaml(
                    new Uri("/Client;component/Resources/ModulesCatalog.xaml", UriKind.Relative));
        }

        protected override DependencyObject CreateShell() {
            Shell shell = new Shell();
            Application.Current.RootVisual = shell;

            return shell;
        }

        protected override void ConfigureContainer() {

            // register the UnityConfiguration Section 
            Unity unity = Unity.CreateFromXaml(
                    new Uri("/Client;component/Resources/UnityConfiguration.xaml", UriKind.Relative));
            unity.Containers.Default.Configure(this.Container);
            // make it available everywere!
            this.Container.RegisterInstance<Unity>(Unity.ConfigurationKey, unity);

            base.ConfigureContainer();

        }

    }
}
